<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                 label-width="68px">
            <el-form-item label="采购订单编码" prop="poNo">
                <el-input v-model="queryParams.poNo" placeholder="请输入采购订单编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购订单行项目号" prop="poItemNo">
                <el-input v-model="queryParams.poItemNo" placeholder="请输入采购订单行项目号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购订单行项目id" prop="poItemId">
                <el-input v-model="queryParams.poItemId" placeholder="请输入采购订单行项目id"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="种类编码" prop="subclassCode">
                <el-input v-model="queryParams.subclassCode" placeholder="请输入种类编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="种类名称" prop="subclassName">
                <el-input v-model="queryParams.subclassName" placeholder="请输入种类名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同编号" prop="conCode">
                <el-input v-model="queryParams.conCode" placeholder="请输入合同编号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同名称" prop="conName">
                <el-input v-model="queryParams.conName" placeholder="请输入合同名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购方公司名称" prop="buyerName">
                <el-input v-model="queryParams.buyerName" placeholder="请输入采购方公司名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购方公司编码" prop="buyerCode">
                <el-input v-model="queryParams.buyerCode" placeholder="请输入采购方公司编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购方物料编码" prop="materialCode">
                <el-input v-model="queryParams.materialCode" placeholder="请输入采购方物料编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购方物料描述" prop="materialDesc">
                <el-input v-model="queryParams.materialDesc" placeholder="请输入采购方物料描述"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购数量" prop="amount">
                <el-input v-model="queryParams.amount" placeholder="请输入采购数量"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同编号" prop="sellerConCode">
                <el-input v-model="queryParams.sellerConCode" placeholder="请输入合同编号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="技术规范流水号" prop="serialNumber">
                <el-input v-model="queryParams.serialNumber" placeholder="请输入技术规范流水号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同签订日期" prop="sellerSignTime">
                <el-input v-model="queryParams.sellerSignTime" placeholder="请输入合同签订日期"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="项目编号" prop="prjCode">
                <el-input v-model="queryParams.prjCode" placeholder="请输入项目编号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="工程项目名称" prop="prjName">
                <el-input v-model="queryParams.prjName" placeholder="请输入工程项目名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="物资编码" prop="matCode">
                <el-input v-model="queryParams.matCode" placeholder="请输入物资编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购技术固化ID" prop="fixedTechid">
                <el-input v-model="queryParams.fixedTechid" placeholder="请输入采购技术固化ID"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同包号" prop="pkgNo">
                <el-input v-model="queryParams.pkgNo" placeholder="请输入合同包号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="物资大类编码" prop="matMaxCode">
                <el-input v-model="queryParams.matMaxCode" placeholder="请输入物资大类编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="物资中类编码" prop="matMedCode">
                <el-input v-model="queryParams.matMedCode" placeholder="请输入物资中类编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="物资小类编码" prop="matMinCode">
                <el-input v-model="queryParams.matMinCode" placeholder="请输入物资小类编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="物资大类名称" prop="matMaxName">
                <el-input v-model="queryParams.matMaxName" placeholder="请输入物资大类名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="物资中类名称" prop="matMedName">
                <el-input v-model="queryParams.matMedName" placeholder="请输入物资中类名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="物资小类名称" prop="matMinName">
                <el-input v-model="queryParams.matMinName" placeholder="请输入物资小类名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="虚拟订单标识" prop="virFlag">
                <el-input v-model="queryParams.virFlag" placeholder="请输入虚拟订单标识"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同生效日期" prop="conValidTime">
                <el-input v-model="queryParams.conValidTime" placeholder="请输入合同生效日期"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同父子ID" prop="parentConId">
                <el-input v-model="queryParams.parentConId" placeholder="请输入合同父子ID"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同ID" prop="conId">
                <el-input v-model="queryParams.conId" placeholder="请输入合同ID"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="支付比例" prop="payRate">
                <el-input v-model="queryParams.payRate" placeholder="请输入支付比例"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="分包编码" prop="bidpkgCode">
                <el-input v-model="queryParams.bidpkgCode" placeholder="请输入分包编码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="招标批次" prop="purprjCode">
                <el-input v-model="queryParams.purprjCode" placeholder="请输入招标批次"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="招标计划名称" prop="purprjName">
                <el-input v-model="queryParams.purprjName" placeholder="请输入招标计划名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="分标名称" prop="subbidName">
                <el-input v-model="queryParams.subbidName" placeholder="请输入分标名称"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="供货单编号" prop="suppMatMode">
                <el-input v-model="queryParams.suppMatMode" placeholder="请输入供货单编号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同最终交货期" prop="cfmDlvTime">
                <el-input v-model="queryParams.cfmDlvTime" placeholder="请输入合同最终交货期"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="合同计划交货日期" prop="dlvTime">
                <el-input v-model="queryParams.dlvTime" placeholder="请输入合同计划交货日期"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="实际收货地址" prop="realRecvAddr">
                <el-input v-model="queryParams.realRecvAddr" placeholder="请输入实际收货地址"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="预计发货期" prop="planDistTime">
                <el-input v-model="queryParams.planDistTime" placeholder="请输入预计发货期"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="预计到货期" prop="planAccpTime">
                <el-input v-model="queryParams.planAccpTime" placeholder="请输入预计到货期"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="收货联系人" prop="recvContact">
                <el-input v-model="queryParams.recvContact" placeholder="请输入收货联系人"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="联系人固定电话" prop="contactTel">
                <el-input v-model="queryParams.contactTel" placeholder="请输入联系人固定电话"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购申请号" prop="purreqCode">
                <el-input v-model="queryParams.purreqCode" placeholder="请输入采购申请号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="采购申请行号" prop="purreqItemCode">
                <el-input v-model="queryParams.purreqItemCode" placeholder="请输入采购申请行号"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="交货方式" prop="dlvMode">
                <el-input v-model="queryParams.dlvMode" placeholder="请输入交货方式"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="变更数量" prop="chgQty">
                <el-input v-model="queryParams.chgQty" placeholder="请输入变更数量"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="变更后数量" prop="chgUpdQty">
                <el-input v-model="queryParams.chgUpdQty" placeholder="请输入变更后数量"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="变更后金额" prop="chgConAmt">
                <el-input v-model="queryParams.chgConAmt" placeholder="请输入变更后金额"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="是否变更" prop="isChanged">
                <el-input v-model="queryParams.isChanged" placeholder="请输入是否变更"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="联系人手机" prop="contactMobile">
                <el-input v-model="queryParams.contactMobile" placeholder="请输入联系人手机"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="更新时间" prop="modifyTime">
                <el-input v-model="queryParams.modifyTime" placeholder="请输入更新时间"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="每页条数" prop="pageSize">
                <el-input v-model="queryParams.pageSize" placeholder="请输入每页条数"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="当前页码" prop="pageNum">
                <el-input v-model="queryParams.pageNum" placeholder="请输入当前页码"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="页数" prop="pageCount">
                <el-input v-model="queryParams.pageCount" placeholder="请输入页数"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="总记录数" prop="total">
                <el-input v-model="queryParams.total" placeholder="请输入总记录数"
                        clearable @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                        v-hasPermi="['develop:FactoryPurchaseMainColumn:add']">新增</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
                        @click="handleUpdate" v-hasPermi="['develop:FactoryPurchaseMainColumn:edit']">修改</el-button>
            </el-col>
            <el-col :span="1.5">
                <el-popconfirm title="确认删除选择的数据项？" @confirm="handleDelete({})">
                    <el-button slot="reference" type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
                               v-hasPermi="['develop:FactoryPurchaseMainColumn:remove']">删除</el-button>
                </el-popconfirm>
            </el-col>
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" size="mini"
                        @click="handleExport" v-hasPermi="['develop:FactoryPurchaseMainColumn:export']">导出</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table border v-loading="loading" :data="dataList" @selection-change="handleSelectionChange" ref="table" :max-height="tableMaxHeight">
            <el-table-column type="selection" width="55" align="center"/>
                    <el-table-column label="主键" align="center" prop="id"/>
            <el-table-column label="状态" align="center" prop="status"/>
            <el-table-column label="备注" align="center" prop="remark"/>
            <el-table-column label="采购订单编码" align="center" prop="poNo"/>
            <el-table-column label="采购订单行项目号" align="center" prop="poItemNo"/>
            <el-table-column label="采购订单行项目id" align="center" prop="poItemId"/>
            <el-table-column label="种类编码" align="center" prop="subclassCode"/>
            <el-table-column label="种类名称" align="center" prop="subclassName"/>
            <el-table-column label="合同编号" align="center" prop="conCode"/>
            <el-table-column label="合同名称" align="center" prop="conName"/>
            <el-table-column label="采购方公司名称" align="center" prop="buyerName"/>
            <el-table-column label="采购方公司编码" align="center" prop="buyerCode"/>
            <el-table-column label="采购方物料编码" align="center" prop="materialCode"/>
            <el-table-column label="采购方物料描述" align="center" prop="materialDesc"/>
            <el-table-column label="采购数量" align="center" prop="amount"/>
            <el-table-column label="合同编号" align="center" prop="sellerConCode"/>
            <el-table-column label="技术规范流水号" align="center" prop="serialNumber"/>
            <el-table-column label="合同签订日期" align="center" prop="sellerSignTime"/>
            <el-table-column label="合同类型" align="center" prop="conType"/>
            <el-table-column label="项目编号" align="center" prop="prjCode"/>
            <el-table-column label="工程项目名称" align="center" prop="prjName"/>
            <el-table-column label="物资编码" align="center" prop="matCode"/>
            <el-table-column label="采购技术固化ID" align="center" prop="fixedTechid"/>
            <el-table-column label="合同包号" align="center" prop="pkgNo"/>
            <el-table-column label="招标批次号" align="center" prop="bidBatCode"/>
            <el-table-column label="固化ID描述" align="center" prop="extDes"/>
            <el-table-column label="物资大类编码" align="center" prop="matMaxCode"/>
            <el-table-column label="物资中类编码" align="center" prop="matMedCode"/>
            <el-table-column label="物资小类编码" align="center" prop="matMinCode"/>
            <el-table-column label="物资大类名称" align="center" prop="matMaxName"/>
            <el-table-column label="物资中类名称" align="center" prop="matMedName"/>
            <el-table-column label="物资小类名称" align="center" prop="matMinName"/>
            <el-table-column label="虚拟订单标识" align="center" prop="virFlag"/>
            <el-table-column label="合同生效日期" align="center" prop="conValidTime"/>
            <el-table-column label="合同父子ID" align="center" prop="parentConId"/>
            <el-table-column label="合同ID" align="center" prop="conId"/>
            <el-table-column label="支付比例" align="center" prop="payRate"/>
            <el-table-column label="分包编码" align="center" prop="bidpkgCode"/>
            <el-table-column label="招标批次" align="center" prop="purprjCode"/>
            <el-table-column label="招标计划名称" align="center" prop="purprjName"/>
            <el-table-column label="分标名称" align="center" prop="subbidName"/>
            <el-table-column label="供货单编号" align="center" prop="suppMatMode"/>
            <el-table-column label="合同最终交货期" align="center" prop="cfmDlvTime"/>
            <el-table-column label="合同计划交货日期" align="center" prop="dlvTime"/>
            <el-table-column label="实际收货地址" align="center" prop="realRecvAddr"/>
            <el-table-column label="预计发货期" align="center" prop="planDistTime"/>
            <el-table-column label="预计到货期" align="center" prop="planAccpTime"/>
            <el-table-column label="收货联系人" align="center" prop="recvContact"/>
            <el-table-column label="联系人固定电话" align="center" prop="contactTel"/>
            <el-table-column label="采购申请号" align="center" prop="purreqCode"/>
            <el-table-column label="采购申请行号" align="center" prop="purreqItemCode"/>
            <el-table-column label="交货方式" align="center" prop="dlvMode"/>
            <el-table-column label="变更数量" align="center" prop="chgQty"/>
            <el-table-column label="变更后数量" align="center" prop="chgUpdQty"/>
            <el-table-column label="变更后金额" align="center" prop="chgConAmt"/>
            <el-table-column label="变更类型" align="center" prop="chgType"/>
            <el-table-column label="是否变更" align="center" prop="isChanged"/>
            <el-table-column label="联系人手机" align="center" prop="contactMobile"/>
            <el-table-column label="更新时间" align="center" prop="modifyTime"/>
            <el-table-column label="每页条数" align="center" prop="pageSize"/>
            <el-table-column label="当前页码" align="center" prop="pageNum"/>
            <el-table-column label="页数" align="center" prop="pageCount"/>
            <el-table-column label="总记录数" align="center" prop="total"/>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit"
                            @click="handleUpdate(scope.row)" v-hasPermi="['develop:FactoryPurchaseMainColumn:edit']">修改</el-button>
                    <el-popconfirm :title="`确认删除当前数据项？`" @confirm="handleDelete(scope.row)"
                                   style="margin-left: 10px;">
                        <el-button slot="reference" size="mini" type="text" icon="el-icon-delete"
                                   v-hasPermi="['develop:FactoryPurchaseMainColumn:remove']">删除</el-button>
                    </el-popconfirm>
                </template>
            </el-table-column>
        </el-table>

        <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getList"/>

        <factoryPurchaseMainColumn-form ref="form" @ok="getList"></factoryPurchaseMainColumn-form>
    </div>
</template>

<script>
    import { deleteAction, getAction } from '@/api/manage'
    import FactoryPurchaseMainColumnForm from '@/views/develop/factory/factoryPurchaseMainColumn/module/FactoryPurchaseMainColumnForm'

    export default {
        name: "FactoryPurchaseMainColumnList",
        components: {
            FactoryPurchaseMainColumnForm,
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 采购订单行项目信息表格数据
                dataList: [],
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
            status: null,
            poNo: null,
            poItemNo: null,
            poItemId: null,
            subclassCode: "60004",
            subclassName: null,
            conCode: null,
            conName: null,
            buyerName: null,
            buyerCode: null,
            materialCode: null,
            materialDesc: null,
            amount: null,
            sellerConCode: null,
            serialNumber: null,
            sellerSignTime: null,
            conType: null,
            prjCode: null,
            prjName: null,
            matCode: null,
            fixedTechid: null,
            pkgNo: null,
            bidBatCode: null,
            extDes: null,
            matMaxCode: null,
            matMedCode: null,
            matMinCode: null,
            matMaxName: null,
            matMedName: null,
            matMinName: null,
            virFlag: null,
            conValidTime: null,
            parentConId: null,
            conId: null,
            payRate: null,
            bidpkgCode: null,
            purprjCode: null,
            purprjName: null,
            subbidName: null,
            suppMatMode: null,
            cfmDlvTime: null,
            dlvTime: null,
            realRecvAddr: null,
            planDistTime: null,
            planAccpTime: null,
            recvContact: null,
            contactTel: null,
            purreqCode: null,
            purreqItemCode: null,
            dlvMode: null,
            chgQty: null,
            chgUpdQty: null,
            chgConAmt: null,
            chgType: null,
            isChanged: null,
            contactMobile: null,
            modifyTime: null,
            pageSize: null,
            pageNum: null,
            pageCount: null,
            total: null
                },
                url: {
                    list:'/factoryPurchaseMainColumn/factoryPurchaseMainColumn/list',
                    remove:'/factoryPurchaseMainColumn/factoryPurchaseMainColumn/',
                    export:'/factoryPurchaseMainColumn/factoryPurchaseMainColumn/export',
                },
                tableMaxHeight: window.innerHeight - 320,
            };
        },
        created() {
            this.getList();
            window.addEventListener('resize', this.getTableHeight);
        },
        destroyed () {
            window.removeEventListener('resize', this.getTableHeight)
        },
        methods: {
            /** 查询采购订单行项目信息列表 */
            getList() {
                this.loading = true;
                getAction(this.url.list, this.queryParams).then(response => {
                    this.dataList = response.rows;
                    this.total = response.total;
                    this.loading = false;
                });
            },
            getTableHeight () {
                this.tableHeight = window.innerHeight - 320
            },
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.handleQuery();
            },
            // 多选框选中数据
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.id)
                this.single = selection.length !== 1
                this.multiple = !selection.length
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.$refs.form.handleAdd();
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.$refs.form.handleUpdate(row);
            },
            /** 删除按钮操作 */
            handleDelete(row) {
                const ids = row.id || this.ids;
                deleteAction(this.url.remove, ids).then(response => {
                    this.getList();
                    this.$modal.msgSuccess("删除成功");
                }).catch(() => {});
            },
            /** 导出按钮操作 */
            handleExport() {
                this.download(this.url.export, {
                    ...this.queryParams
                }, `factoryPurchaseMainColumn_${new Date().getTime()}.xlsx`)
            },
  }
};
</script>
